#include "KmyWorldComponent.h"
#include "KmyWorld.h"

KmyWorldComponent::KmyWorldComponent()
{
}

int KmyWorldComponent::getGlobalX(){
    if (parent!=NULL){
        if (parent->getNodeType() == KmyNode::NODE_TYPE_WORLD){
            KmyWorld *world = (KmyWorld*)parent;
            return x - world->getCamera()->x;
        }else{
            return parent->getGlobalX()+x;
        }
    }else{
        return x;
    }
}

int KmyWorldComponent::getGlobalY(){
    if (parent!=NULL){
        if (parent->getNodeType() == KmyNode::NODE_TYPE_WORLD){
            KmyWorld *world = (KmyWorld*)parent;
            return y - world->getCamera()->y;
        }else{
            return parent->getGlobalY()+y;
        }
    }else{
        return y;
    }
}
